package com.djx.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @ClassName: ThreadTaskController
 * @Description: TODO
 * @author: 星~
 * @date: 2021/10/9 0009 下午 16:38
 */
@RequestMapping("/threadTask")
@RestController
public class ThreadTaskController {

    public static ExecutorService executor = Executors.newFixedThreadPool(50);
    int i = 0;

    @RequestMapping("/task01")
    public String task01() throws InterruptedException {

        CompletableFuture.runAsync(() -> {

            try {
                Thread.sleep(7000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("我是线程号为： " + Thread.currentThread().getId() + " 的任务");
        }, executor);
        i+=1;
        System.err.println(i);
        return "111";
    }


}
